home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-09-26 | 1.7 KB | 61 lines | [TEXT/ObLi] |
- MODULE ViewPict; (* od jul-93 *)
-
- (* A sample MacOberonLite program that shows how to open and
- display a Macintosh PICT file. *)
-
- IMPORT
- SYSTEM, TB:= MacToolbox, ME:=MacMemory, TE:=MacText, IM:=MacImaging, MF:=MacFiles,
- MP:=MacProcesses;
-
- PROCEDURE InitMac;
- BEGIN
- IM.InitGraf(IM.QuickDraw.thePort);
- TE.InitFonts;
- TB.InitWindows;
- TB.InitMenus;
- TE.TEInit;
- TB.InitDialogs(NIL);
- IM.InitCursor;
- END InitMac;
-
- PROCEDURE OpenPict;
- VAR
- myTypes : MF.SFTypeList;
- myReply : MF.StandardFileReply;
- myRef : INTEGER;
- fsize : LONGINT;
- myPic : IM.PicHandle;
- err : INTEGER;
- myWindow : TB.WindowPtr;
- BEGIN
- myTypes[0]:=50494354H; (* PICT *)
- MF.StandardGetFile(NIL, 1, myTypes, myReply);
- IF myReply.sfGood THEN
- err:=MF.FSpOpenDF(myReply.sfFile, 0, myRef);
- err:=MF.GetEOF(myRef, fsize);
- err:=MF.SetFPos(myRef, 1, 512);
- DEC(fsize, 512); (* strip PICT-header *)
- SYSTEM.PUTREG(0, fsize);
- ME.NewHandle;
- SYSTEM.GETREG(8, myPic);
- IF myPic=NIL THEN HALT(20) END; (* Not enough memory *)
- err:=MF.FSRead(myRef, fsize, SYSTEM.VAL(ME.Ptr, myPic.p));
- err:=MF.FSClose(myRef); (* I left out most error checking in this demo app! *)
-
- myWindow:=TB.NewCWindow(NIL, IM.QuickDraw.screenBits.bounds, '', TRUE, 1,
- SYSTEM.VAL(TB.WindowPtr, -1), FALSE, 0);
- IM.SetPort(myWindow);
- IM.OffsetRect(myPic.p.picFrame, -myPic.p.picFrame.left, -myPic.p.picFrame.top);
- IM.DrawPicture(myPic, myPic.p.picFrame);
-
- REPEAT UNTIL TB.Button();
- TB.DisposeWindow(myWindow)
- END
- END OpenPict;
-
- BEGIN
- InitMac;
- OpenPict;
- MP.ExitToShell
- END ViewPict.
-